package com.lyz.dataStructure.LeetCode.dongtaiguihua;

/*
leetcode 198题 打家劫舍
 */
public class Solution {

    public static void main(String[] args) {
        int[] arr = {2,9,7,5,8};
        System.out.println(rob(arr));
    }

    public static int rob(int[] arr){
        int a = 0,b=0, c =0;
        for(int i =0;i<arr.length;i++){
            c =Math.max(a+arr[i],b);
            a =b;
            b =c;
        }
        return  b;
    }
}
